/**
 * <copyright>
 * </copyright>
 *

 */
package org.dslintegration.mRules.impl;

import java.util.Collection;

import org.dslintegration.mRules.MRulesPackage;
import org.dslintegration.mRules.MergeRules;
import org.dslintegration.mRules.Rule;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Merge Rules</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link org.dslintegration.mRules.impl.MergeRulesImpl#getMetamodelPathLeft <em>Metamodel Path Left</em>}</li>
 *   <li>{@link org.dslintegration.mRules.impl.MergeRulesImpl#getMetamodelPathRight <em>Metamodel Path Right</em>}</li>
 *   <li>{@link org.dslintegration.mRules.impl.MergeRulesImpl#getDefaultDominant <em>Default Dominant</em>}</li>
 *   <li>{@link org.dslintegration.mRules.impl.MergeRulesImpl#getRules <em>Rules</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class MergeRulesImpl extends MinimalEObjectImpl.Container implements MergeRules
{
  /**
   * The default value of the '{@link #getMetamodelPathLeft() <em>Metamodel Path Left</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getMetamodelPathLeft()
   * @generated
   * @ordered
   */
  protected static final String METAMODEL_PATH_LEFT_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getMetamodelPathLeft() <em>Metamodel Path Left</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getMetamodelPathLeft()
   * @generated
   * @ordered
   */
  protected String metamodelPathLeft = METAMODEL_PATH_LEFT_EDEFAULT;

  /**
   * The default value of the '{@link #getMetamodelPathRight() <em>Metamodel Path Right</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getMetamodelPathRight()
   * @generated
   * @ordered
   */
  protected static final String METAMODEL_PATH_RIGHT_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getMetamodelPathRight() <em>Metamodel Path Right</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getMetamodelPathRight()
   * @generated
   * @ordered
   */
  protected String metamodelPathRight = METAMODEL_PATH_RIGHT_EDEFAULT;

  /**
   * The default value of the '{@link #getDefaultDominant() <em>Default Dominant</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getDefaultDominant()
   * @generated
   * @ordered
   */
  protected static final String DEFAULT_DOMINANT_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getDefaultDominant() <em>Default Dominant</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getDefaultDominant()
   * @generated
   * @ordered
   */
  protected String defaultDominant = DEFAULT_DOMINANT_EDEFAULT;

  /**
   * The cached value of the '{@link #getRules() <em>Rules</em>}' containment reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getRules()
   * @generated
   * @ordered
   */
  protected EList<Rule> rules;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected MergeRulesImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return MRulesPackage.Literals.MERGE_RULES;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getMetamodelPathLeft()
  {
    return metamodelPathLeft;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setMetamodelPathLeft(String newMetamodelPathLeft)
  {
    String oldMetamodelPathLeft = metamodelPathLeft;
    metamodelPathLeft = newMetamodelPathLeft;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, MRulesPackage.MERGE_RULES__METAMODEL_PATH_LEFT, oldMetamodelPathLeft, metamodelPathLeft));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getMetamodelPathRight()
  {
    return metamodelPathRight;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setMetamodelPathRight(String newMetamodelPathRight)
  {
    String oldMetamodelPathRight = metamodelPathRight;
    metamodelPathRight = newMetamodelPathRight;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, MRulesPackage.MERGE_RULES__METAMODEL_PATH_RIGHT, oldMetamodelPathRight, metamodelPathRight));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getDefaultDominant()
  {
    return defaultDominant;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setDefaultDominant(String newDefaultDominant)
  {
    String oldDefaultDominant = defaultDominant;
    defaultDominant = newDefaultDominant;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, MRulesPackage.MERGE_RULES__DEFAULT_DOMINANT, oldDefaultDominant, defaultDominant));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<Rule> getRules()
  {
    if (rules == null)
    {
      rules = new EObjectContainmentEList<Rule>(Rule.class, this, MRulesPackage.MERGE_RULES__RULES);
    }
    return rules;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case MRulesPackage.MERGE_RULES__RULES:
        return ((InternalEList<?>)getRules()).basicRemove(otherEnd, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case MRulesPackage.MERGE_RULES__METAMODEL_PATH_LEFT:
        return getMetamodelPathLeft();
      case MRulesPackage.MERGE_RULES__METAMODEL_PATH_RIGHT:
        return getMetamodelPathRight();
      case MRulesPackage.MERGE_RULES__DEFAULT_DOMINANT:
        return getDefaultDominant();
      case MRulesPackage.MERGE_RULES__RULES:
        return getRules();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @SuppressWarnings("unchecked")
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case MRulesPackage.MERGE_RULES__METAMODEL_PATH_LEFT:
        setMetamodelPathLeft((String)newValue);
        return;
      case MRulesPackage.MERGE_RULES__METAMODEL_PATH_RIGHT:
        setMetamodelPathRight((String)newValue);
        return;
      case MRulesPackage.MERGE_RULES__DEFAULT_DOMINANT:
        setDefaultDominant((String)newValue);
        return;
      case MRulesPackage.MERGE_RULES__RULES:
        getRules().clear();
        getRules().addAll((Collection<? extends Rule>)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case MRulesPackage.MERGE_RULES__METAMODEL_PATH_LEFT:
        setMetamodelPathLeft(METAMODEL_PATH_LEFT_EDEFAULT);
        return;
      case MRulesPackage.MERGE_RULES__METAMODEL_PATH_RIGHT:
        setMetamodelPathRight(METAMODEL_PATH_RIGHT_EDEFAULT);
        return;
      case MRulesPackage.MERGE_RULES__DEFAULT_DOMINANT:
        setDefaultDominant(DEFAULT_DOMINANT_EDEFAULT);
        return;
      case MRulesPackage.MERGE_RULES__RULES:
        getRules().clear();
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case MRulesPackage.MERGE_RULES__METAMODEL_PATH_LEFT:
        return METAMODEL_PATH_LEFT_EDEFAULT == null ? metamodelPathLeft != null : !METAMODEL_PATH_LEFT_EDEFAULT.equals(metamodelPathLeft);
      case MRulesPackage.MERGE_RULES__METAMODEL_PATH_RIGHT:
        return METAMODEL_PATH_RIGHT_EDEFAULT == null ? metamodelPathRight != null : !METAMODEL_PATH_RIGHT_EDEFAULT.equals(metamodelPathRight);
      case MRulesPackage.MERGE_RULES__DEFAULT_DOMINANT:
        return DEFAULT_DOMINANT_EDEFAULT == null ? defaultDominant != null : !DEFAULT_DOMINANT_EDEFAULT.equals(defaultDominant);
      case MRulesPackage.MERGE_RULES__RULES:
        return rules != null && !rules.isEmpty();
    }
    return super.eIsSet(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public String toString()
  {
    if (eIsProxy()) return super.toString();

    StringBuffer result = new StringBuffer(super.toString());
    result.append(" (metamodelPathLeft: ");
    result.append(metamodelPathLeft);
    result.append(", metamodelPathRight: ");
    result.append(metamodelPathRight);
    result.append(", defaultDominant: ");
    result.append(defaultDominant);
    result.append(')');
    return result.toString();
  }

} //MergeRulesImpl
